package com.pianke.yc.test.Activity;



import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.Menu;
import android.view.MenuItem;

import com.pianke.yc.test.Fragment.AcceptFragment;
import com.pianke.yc.test.R;

import java.util.ArrayList;

public class MainActivity extends FragmentActivity {

    private AcceptFragment mAcceptFragment;
    private ArrayList<Fragment> mListFragment;
    private SwipeRefreshLayout mSwip;
    private ViewPager mViewPage;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mViewPage = (ViewPager) findViewById(R.id.ViewPager);

        mAcceptFragment = new AcceptFragment();
        mListFragment = new ArrayList<>();

        mListFragment.add(mAcceptFragment);

        FragmentManager fm = getSupportFragmentManager();
        mViewPage.setAdapter(new FragmentPagerAdapter(fm) {
            @Override
            public Fragment getItem(int position) {
                return mListFragment.get(position);
            }

            @Override
            public int getCount() {
                return mListFragment.size();
            }
        });

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}
